package home_8_25.view.impl;


import home_8_25.dao.AccountDao;
import home_8_25.dao.impl.AccountDaoImpl;

import static home_8_25.util.ReadText.getIn;

public class AccountView extends BusinessView {
    private AccountDao accountDao = new AccountDaoImpl();
    private String name;

    public AccountDao getAccountDao() {
        return accountDao;
    }

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    private String amount;
    private String time;
    private String money;
    private void account() {
        System.out.println(" 1.收支明细");
        System.out.println(" 2.登记收入");
        System.out.println(" 3.登记支出");
        System.out.println("请选择");
        int n = getIn().nextInt();

        switch (n){
            case 1:
                accupdate();
                break;
            case 2:
                accadd();
                break;
            case 3:
                accdelete();
                
                break;
            case 4:
                break;
            default:
                System.out.println("请输入正确指令");
        }
    }

    private void accdelete() {
        String id = getInfo().get("busid").toString();
        int row = accountDao.accdelete("");
        if (row > 0) {
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
    }

    private void accadd() {
        String id = getInfo().get("busid").toString();
        int row = accountDao.accadd("name,price,info,id");
        if (row > 0) {
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
    }

    private void accupdate() {
        String id = getInfo().get("busid").toString();
        int row = accountDao.accupdate("name,price,info,id");
        if (row > 0) {
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
    }
}
